package Feb_14.TestCommunication;

public class PrintNum implements Runnable{
    int num = 1;

    @Override
    public void run() {
        while (true){
            synchronized (this){
                notify();
                if (num<=100){
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName()+":"+num);
                    num++;
                }else {
                    break;
                }
                try {
                    wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
